export default function wxpay(data, callback){
  function onBridgeReady(){
    window.WeixinJSBridge.invoke(
      'getBrandWCPayRequest', {
        "appId":data.AppID,     //公众号名称，由商户传入     
        "timeStamp":""+data.Timestamp,        //时间戳，自1970年以来的秒数     
        "nonceStr": data.NonceStr, //随机串     
        "package":data.Package,     
        "signType": data.SignType,      //微信签名方式：     
        "paySign": data.Sign, //微信签名 
      },
      function(res){
        callback(res)
      }); 
  }
  if(typeof WeixinJSBridge == "undefined"){
      if( document.addEventListener ){
        document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
      }else if (document.attachEvent){
        document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
        document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
      }
  }else{
    onBridgeReady();
  }
}